package icegps.com.pingdj.map.draw;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

import java.util.HashMap;
import java.util.Set;

import icegps.com.pingdj.App;
import icegps.com.pingdj.R;
import icegps.com.pingdj.map.bean.MapStatus;
import icegps.com.pingdj.map.bean.MapText;


/**
 * Created by 111 on 2018/3/5.
 */

public class DrawText {

    private Paint textPaint;
    private MapStatus mapStatus;
    private final int sp16;
    private float multiple;

    public DrawText(MapStatus mapStatus) {
        this.mapStatus = mapStatus;
        textPaint = new Paint();
        textPaint.setColor(Color.BLACK);
        textPaint.setTextAlign(Paint.Align.CENTER);
        sp16 = App.getInstance().getResources().getDimensionPixelSize(R.dimen.sp_16);
        textPaint.setTextSize(sp16);
    }


    public void drawText(Canvas canvas, HashMap<String, MapText> mapTextHashMap) {
        multiple = mapStatus.getMultiple();
        Set<String> strings = mapTextHashMap.keySet();
        for (String string : strings) {

            MapText mapText = mapTextHashMap.get(string);
            canvas.drawText(mapText.text, (mapText.x+mapText.lentgth/2) * multiple,( mapText.y+mapText.lentgth/2) * multiple, textPaint);
        }


    }
}
